<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
        // 1 原型继承
        // 让原型等于另一个要继承的实例
        function  Person() {
            this.name = "zs";
            this.age = 23
        }

        Person.prototype.sayhi = function() {
            console.log(aaaaaaaaaaa)
        }


        function  Student() {
            this.score = 60
        }
        
        Student.prototype = new Person();
        Student.prototype.constructor = Student;
        var s1 = new Student("zs",34)   //实参在这儿
        console.log(s1)
        // 原型继承可以继承属性和方法,缺点是不能传递参数
        
        // 2 借用父类型的构造函数去继承父类型的属性
        // function Common(name,age,gender) {
        //     this.name = name
        //     this.age = age
        //     this.gender = gender
        // }
        // function Student(name,age,gender,score) {
        //     // 在这里想要common里的属性
        //     Common.call(this,name,age,gender)   //common内部的this指向Student的实例
        //     this.score = score
        // }
        // const s = new Student("ss",23,"男",90)
        // console.log(s)

        
    </script>
</body>
</html>